<?php

class Default_Form_Search extends Zend_Form
{

    public function init()
    {
        $keyword = new Zend_Form_Element_Text("keyword");
        $keyword->removeDecorator("HtmlTag")
        		->setValue("Từ khóa tìm kiếm")
        		->setAttribs(array("onblur"=>"if(this.value == '') this.value='Từ khóa tìm kiếm'",
        				"onfocus"=>"if(this.value == 'Từ khóa tìm kiếm') this.value = ''"
        		))
        		->removeDecorator("Label");
        
        $se_manufacture = new Zend_Form_Element_Select("searchmanu");
        $se_manufacture->addMultiOptions(array(
        		"0"=>"Chọn hãng sản xuất..."
        ))->removeDecorator("HtmlTag")->removeDecorator("Label");
        
        $price_from = new Zend_Form_Element_Select("pricefrom");
        $price_from->addMultiOptions(array(
        		0		=>	'Từ giá...',
        		1000000=>$this->FormatNumber(1000000),
        		2000000=>$this->FormatNumber(2000000),
        		4000000=>$this->FormatNumber(4000000),
        		6000000=>$this->FormatNumber(6000000),
        		8000000=>$this->FormatNumber(8000000),
        		10000000=>$this->FormatNumber(10000000),
        		14000000=>$this->FormatNumber(14000000),
        ))
        		->removeDecorator("HtmlTag")
        		->removeDecorator("Label");
        			
        
        $price_to = new Zend_Form_Element_Select("priceto");
        $price_to->addMultiOptions(array(
        		0 => "Đến giá...",
        		16000000=>$this->FormatNumber(16000000),
        		20000000=>$this->FormatNumber(20000000),
        		22000000=>$this->FormatNumber(22000000),
        		26000000=>$this->FormatNumber(26000000),
        		30000000=>$this->FormatNumber(30000000),
        		34000000=>$this->FormatNumber(34000000),
        		40000000=>$this->FormatNumber(40000000),
        		46000000=>$this->FormatNumber(46000000),
        		50000000=>$this->FormatNumber(50000000),
        ))->removeDecorator("HtmlTag")
        	->removeDecorator("Label");
        
        $search_submit = new Zend_Form_Element_Submit("submit");
        $search_submit->setLabel("Tìm kiếm")->removeDecorator("DtDdWrapper");
        
        $this->addElements(array($keyword, $se_manufacture, $price_from, $price_to, $search_submit));
    }
    
    private function FormatNumber($number){
    	return number_format($number, 0, ',', '.') .'đ';
    }


}

